<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/header', TEMPLATE_INCLUDEPATH)) : (include template('public/header', TEMPLATE_INCLUDEPATH));?>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/comhead', TEMPLATE_INCLUDEPATH)) : (include template('public/comhead', TEMPLATE_INCLUDEPATH));?>

<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li  <?php  if($type=='all') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('branchslist',array('type'=>all));?>">全部门店</a></li>
    <li   <?php  if($type=='wait') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('branchslist',array('type'=>wait,'status'=>1));?>">营业门店</a></li>
    <li   <?php  if($type=='ok') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('branchslist',array('type'=>ok,'status'=>2));?>">停业门店</a></li>
</ul>
<br>
<div class="row ygrow">
    <div class="col-lg-12">
        <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="branchslist" />
            <div class="input-group">
                <input type="text" name="keywords" class="form-control" placeholder="请输入门店名称">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
        </div>
    </div><!-- /.col-lg-6 -->
</div>

<div class="main ">

    <div class="panel panel-default">
        <div class="panel-heading">
            门店列表
        </div>

        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row" id="accordion">


                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <td  class="store_td1 col-md-1">编号</td>
                        <td  class="col-md-1">门店名称</td>
                        <td  class="col-md-1">门店详细地址 </td>
                        <td  class="col-md-1">是否开启送车上门（上门范围） </td>
                        <td  class="col-md-1"> 营业时间</td>
                        <td  class="col-md-1"> 服务热线</td>
                        <td class="col-md-1"> 门店电话</td>
                        <td class="col-md-1">状态</td>
                        <td>操作</td>
                    </tr>

                    <?php  if(is_array($info)) { foreach($info as $key => $item) { ?>
                    <tbody>
                    <tr class="yg5_tr2" >

                        <td><?php  echo $item['id'];?></td>
                        <td><?php  echo $item['name'];?></td>
                        <td><?php  echo $item['address'];?></td>
                        <td><?php  if($item['ranges']==0) { ?>不上门
                            <?php  } else { ?> 支持送车上门（<?php  echo $item['ranges'];?>km内）
                            <?php  } ?>
                        </td>
                        <td><?php  echo $item['business_hours'];?></td>
                        <td><?php  echo $item['service_tel'];?></td>
                        <td><?php  echo $item['shop_tel'];?></td>
                        <td>
                            <?php  if($item['status']==1) { ?>
                            <span class="label storered">营业中</span>
                            <?php  } else { ?>
                            <span class="label storeblue">已停业</span>
                            <?php  } ?>
                        </td>

                        <td>
                            <?php  if($item['status']==1) { ?>
                            <a href="<?php  echo $this->createWebUrl('branchslist', array('id' => $item['id'],'op'=>change,'states'=>2))?>">
                                <span class="btn btn-md ygyouhui2">点击关闭</span>
                            </a>
                            <?php  } else { ?>
                            <a href="<?php  echo $this->createWebUrl('branchslist', array('id' => $item['id'],'op'=>change,'states'=>1))?>">
                                <span class="btn btn-md storegrey2">点击启用</span>
                            </a>
                            <?php  } ?>
                            <a href="<?php  echo $this->createWebUrl('branch', array('id' => $item['id']))?>" class="storespan btn btn-xs">
                                <span class="fa fa-pencil"></span>
                                <span class="bianji">编辑
                                    <span class="arrowdown"></span>
                                 </span>
                            </a>
                            <a href="javascript:;" class="storespan btn btn-xs" onclick="del(<?php  echo $item['id'];?>)">
                                <span class="fa fa-trash-o"></span><span class="bianji">删除<span class="arrowdown"></span></span>
                            </a>
                            <a href="<?php  echo $this->createWebUrl('branchadminlist',array('bid'=>$item['id']));?>"><button class="btn-bottoms btn btn-default btn-xs">管理员列表</button></a>
                            <!--<a href="<?php  echo $this->createWebUrl('branchslist', array('id' => $item['id'],'op'=>delete) )?>" class="storespan btn btn-xs" >-->
                                <!--<span class="fa fa-trash-o"></span>-->
                                <!--<span class="bianji">删除-->
                                    <!--<span class="arrowdown"></span>-->
                                <!--</span>-->
                            <!--</a>-->
                        </td>
                        <!--<td>-->
                        <!--<a class="fxiala" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php  echo $row['id'];?>">-->
                        <!--<span class="fa fa-chevron-down"></span>-->
                        <!--</a>-->
                        <!--</td>-->
                    </tr>
                    </tbody>
                    <?php  } } ?>
                    <?php  if(empty($item)) { ?>
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无地址信息
                        </td>
                    </tr>
                    <?php  } ?>
                </table>
            </div>
        </div>

    </div>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-1").show();
        $("#yframe-1").addClass("wyactive");
    })
    function del(id) {
        var ret = confirm("删除前请确认该门店所有车辆均已下架，您确定删除吗？")
        if (ret==true){
            $.ajax({
                type:"POST",
                url:"<?php  echo $this->createWebUrl('branchslist',array('op'=>delete))?>",
                dataType:"JSON",
                data:{id:id},
                success:function(res){
                    console.log(res);
                    location.reload();
                    // if(res.status == 1) {
                    //     layer.msg(res.message, {icon: 1});
                    //     location.href ="<?php  echo $this->createWebUrl('renting')?>";
                    // }else{
                    //     layer.msg(res.message, {icon: 6});
                    //     location.href =res.url;
                    // }
                }
            })
        }
    }
</script>